/**
 * 
 */
package src.model.gameObject.ability;

import src.model.gameObject.PlayerGameObject;
import src.model.gameWorld.ActualMap;
import src.model.gameWorld.PlayerLookupTable;
import src.model.gameWorld.Position;

/**
 * @author Tristan
 *
 */
public class UnloadUnit extends ActiveAbility {

	private PlayerGameObject carrying;
	private ActualMap am;
	private LoadUnit loader;
	/**
	 * @param pgo
	 * @param aType
	 */
	public UnloadUnit(PlayerGameObject owner, PlayerGameObject carrying, PlayerLookupTable playerLookup, ActualMap am, LoadUnit loader) {
		super(owner, AbilityType.UNLOADUNIT, playerLookup);
		this.carrying = this.carrying;
		this.am = am;
		this.loader = loader;
	}

	public AbilityReturnResult execute(Position... position){
		if (am.placeObject(carrying, position[0])){
			PlayerGameObject pgo = super.gameObject();
			pgo.addActiveAbility(loader);
			pgo.removeActiveAbility(this);
			return AbilityReturnResult.SUCCESS;
		}
		return AbilityReturnResult.IMPOSSIBLE;
	}
	
	public boolean queueToMission(Position...position){
		if (position.length == 0)  return false;
		super.gameObject().enqueueAbility(this, position);
		return true;
	}
	
	public void destroySub(){
		// TODO: IMPLEMENT!!!!
	}
}
